require('../less/password.less')

require('../fonts/iconfont.css')



document.ready(function () {

    /* utils.showToast('chenggong', '登录成功'); */

    /* 获取账号密码 */
    const haoma = document.querySelector("#haoma")
    const mima1 = document.querySelector("#mima1")
    const denglu = document.querySelector(".denglu")
    denglu.addEventListener("click", function () {
        console.log(haoma.value);
        console.log(mima1.value);
        $http.post("/users/login", { account: haoma.value, password: mima1.value }, function (res) {
            if (res.status === 0) {
                utils.showToast('chenggong', '登录成功');
                /*  alert("登录成功") */
                setInterval(function () {

                    /* 跳转前将用户id保存到本地存储中 写了这个代码就要登录一次保存数据,首页里面也能看到数据*/
                    localStorage.setItem("userId", res.data.user.userId)


                    location.href = "./home.html"
                }, 3000)


            } else {
                /*  alert(res.msg) */
                utils.showToast('shibai', '登录失败');
            }
        })
    })
})



/**
* 获取元素
*/
/*  const account = document.querySelector('#account')
 const password = document.querySelector('#password')
 const loginbtn = document.querySelector('#loginbtn') */

/**
 * 登录
 */
/* loginbtn.addEventListener('click', function (){
    $http.post('/users/login', {account: account.value, password: password.value }, function (res){
        if( res.status === 0){
            alert('登录成功')
            location.href = './home.html'
        }else{
            alert(res.msg)
        }
    })
}) */
